﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	printf("11111\n");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//VALID 表示结果合法
//INVALID 表示结果非法
enum State
{
	VALID,//0
	INVALID//1
};
enum State state = INVALID;
​
int my_atoi(char *str)
{
	int flag = 1;
	long long ret = 0;
	assert(str);
	state = INVALID;
	while (isspace(*str))
	{
		str++;
	}
	if (*str == '\0')
	{
		return 0;
	}
	if (*str == '+')
	{
		str++;
	}
	else if (*str == '-')
	{
		flag = -1;
		str++;
	}
	while (isdigit(*str))
	{
		ret = ret * 10 + flag * (*str - '0');
		if ((ret > INT_MAX) || (ret < INT_MIN))
		{
			return 0;
		}
		str++;
	}
	if (*str == '\0')
	{
		state = VALID;
		return (int)ret;
	}
	else
	{
		return (int)ret;
	}
}
​
int main()
{
	char *p = "-1212212121212";
	printf("%d\n", my_atoi(p));
	return 0;
}

char * mystrncat(char * dst, const char * src, size_t n)
{
	char * tmp = dst;

	while (*dst)
	{
		dst++;
	}

	int i;
	for (i = 0; src[i] && i < n; i++)
	{
		dst[i] = src[i];
	}

	dst[i] = 0;
	return tmp;
}

char * mystrncpy(char * dst, const char * src, size_t n)
{
	int i;
	for (i = 0; src[i] && i < n; i++)
	{
		dst[i] = src[i];
	}
	//应该是等于
	if (i == n)
	{
		dst[i] = 0;
	}
	return dst;
}

void findTwoNum(int arr[], int n, int * pnum1, int * pnum2)
{
	int i;
	int sum = 0;
	​
	for (i = 0; i < 9; i++)
	{
		sum ^= arr[i];
	} //先找到两个数互相异或的结果
	​
		int pos;
	for (i = 0; i < 32; i++)
	{
		if (sum & 1 << i)
		{
			pos = i;
			break;
		}
	} //再找到有分歧的一位。在这一位上，两个数一定是一个1一个0
	​
		*pnum1 = *pnum2 = 0;
	for (i = 0; i < 10; i++)
	{
		if (arr[i] & 1 << pos)
		{
			*pnum1 ^= arr[i]; //这一位是1的，放在数1里
		}
		else
		{
			*pnum2 ^= arr[i]; //这一位是0的，放在数2里
		}
	}
}
